import QtQuick
import QtQuick.Controls


Rectangle {
    signal wWindowsCloseedCmd()
    signal wWindowsMinimizedCmd()
    signal wWindowsMaximizedCmd()
    signal wPositionChanged(x:int,y:int)
    property int iconSize: 15

    id: root
    Row {
        anchors.fill: parent
        spacing: 0
        HMoveableBar {
            height: root.height
            width: root.width - btns.width
            onWPositionChanged:(x,y) => {
                root.wPositionChanged(x,y)
            }
        }

        Rectangle {
            id: btns
            width: 3 * minBtn.width
            height: root.height
            Row {
                anchors.fill: parent
                Button {
                    id: minBtn
                    text: "最小化"
                    width: root.height+10
                    height: root.height
                    icon.source: 'qrc:/img/icon/min.png'
                    icon.width: iconSize
                    icon.height: iconSize
                    background: Rectangle{
                        border.width: 0
                        color:'#ededed'
                        MouseArea {
                            anchors.fill: parent
                            hoverEnabled: true
                            onEntered: parent.color = '#e1e1e1' // 鼠标悬停时的颜色
                            onExited: parent.color = '#ededed' // 鼠标离开时的颜色
                        }
                    }
                    onClicked: {
                       root.wWindowsMinimizedCmd()
                    }
                }

                Button {
                    id: maxBtn
                    width: root.height+10
                    height: root.height
                    icon.source: 'qrc:/img/icon/max.png'
                    icon.width: iconSize
                    icon.height: iconSize
                    background: Rectangle{
                        border.width: 0
                        color:'#ededed'
                        MouseArea {
                            anchors.fill: parent
                            hoverEnabled: true
                            onEntered: parent.color = '#e1e1e1' // 鼠标悬停时的颜色
                            onExited: parent.color = '#ededed' // 鼠标离开时的颜色
                        }
                    }
                    onClicked: {
                        root.wWindowsMaximizedCmd()
                    }
                }
                Button {
                    id: closeBtn
                    // text: "关闭"
                    width: root.height+10
                    height: root.height
                    icon.source: 'qrc:/img/icon/close.png'
                    icon.width: iconSize+10
                    icon.height: iconSize
                    background: Rectangle{
                        border.width: 0
                        color:'#ededed'
                        MouseArea {
                            anchors.fill: parent
                            hoverEnabled: true
                            onEntered: parent.color = '#ed4c4c' // 鼠标悬停时的颜色
                            onExited: parent.color = '#ededed' // 鼠标离开时的颜色
                        }
                    }
                    onClicked: {
                        root.wWindowsCloseedCmd()
                    }
                }
            }
        }
    }
}
